<?php

function search_party( $FilterCondition )
{
	//初始化过滤条件全部为-1，即不起作用。
	$filter['cat']=-1;
	$filter['industry']=-1;
	$filter['facility']=-1;
	$filter['page']=1;
	foreach( $FilterCondition as $key => $value )
	{
		if($key == 'cat') //说明遇到一个过滤条件cat
		{
			$filter['cat'] = $value;
		}
		else if($key == 'industry')
		{
			$filter['industry'] = $value;
		}
		else if($key == 'facility')
		{
			$filter['facility'] = $value;
		}
		else if($key == 'page')
		{
			$filter['page'] = $value;
		}
	}
	//至此，过滤条件赋好了值。
    
	//在这里应该将这些过滤条件组织成serviceUrl的参数，然后调用serviceUrl。
	//可能涉及到多个系统，所以会调用多次的serviceUrl。

	//将serviceUrl的结果，组织成XML，即与sit的接口格式。
	//在这里只是试验用的，写死成固定的XML了。
    $xml='';
	  {
		$dom = new DOMDocument("1.0"); 
		
		$party_list = Array();
		$party_list[] = array( 'pic' => 'http://i2.j.cn/photo/pics/aa7aee932a559857.jpg',
							   'name' => 'PCEC恩埃埃悌信息技术学院',
							   'page_url'=> 'http://sh.j.cn/47675.html#wrap',
							   'address' => '徐汇区漕溪北路88号圣爱广场707--709单元',
							   'contact' => '021-54893223',
							   'refresh' => '2011-11-11 18:12',
							   'message' => '亲们，明天所有课程打8折啊！'
							  );
		$party_list[] = array( 'pic' => 'http://i2.j.cn/photo/20110419/dab64cb841a.114.110.jpg',
							   'name' => '巴士一汽驾校',
							   'page_url'=> 'http://sh.j.cn/64084.html#wrap',
							   'address' => '上海市宝山顾陈路388号',
							   'contact' => '4001-666-767转2730',
							   'refresh' => '2011-11-11 18:12',
							   'message' => '一周内按学员地址就近分配师傅接学员上车练习'
							  );
		$party_list[] = array( 'pic' => 'http://i2.j.cn/photo/pics/f188ee6b3acd288f.jpg',
							   'name' => '上海莘岚空调安装维修服务有限公司',
							   'page_url'=> 'http://sh.j.cn/47503.html#wrap',
							   'address' => '上海市凌云路406号',
							   'contact' => '021-48682368',
							   'refresh' => '2011-11-11 18:12',
							   'message' => '上海莘岚空调维修安装服务公司,是多年专业从事家用空调安装、拆装、移机、清洗保养、检测加氟'
							  );

		$root = $dom->createElement("party_list");
		$dom->appendChild($root); 
		
		foreach( $party_list as $party )
		{
			$p = $dom->createElement("party");

			$pic = $dom->createElement("pic");
			$txt = $dom->createTextNode( $party['pic'] );
			$pic->appendChild($txt);
			$p->appendChild($pic);

			$name = $dom->createElement("name");
			$txt = $dom->createTextNode( $party['name'] );
			$name->appendChild($txt);
			$p->appendChild($name);

			$page_url = $dom->createElement("page_url");
			$txt = $dom->createTextNode( $party['page_url'] );
			$page_url->appendChild($txt);
			$p->appendChild($page_url);

			$address = $dom->createElement("address");
			$txt = $dom->createTextNode( $party['address'] );
			$address->appendChild($txt);
			$p->appendChild($address);

			$contact = $dom->createElement("contact");
			$txt = $dom->createTextNode( $party['contact'] );
			$contact->appendChild($txt);
			$p->appendChild($contact);

			$refresh = $dom->createElement("refresh");
			$txt = $dom->createTextNode( $party['refresh'] );
			$refresh->appendChild($txt);
			$p->appendChild($refresh);

			$message = $dom->createElement("message");
			$txt = $dom->createTextNode( $party['message'] );
			$message->appendChild($txt);
			$p->appendChild($message);

			$root->appendChild($p);
		}
		// save and display tree 
		$xml = $dom->saveXML();
	  }


	  return $xml;
	  //print_r($filter);
	  //return "success search party<br/>";
}


?>